package com.ltmall.api.util;

import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;

public class RequestToBean {
    @SuppressWarnings("rawtypes")
    public static void populate(HttpServletRequest request, Object obj) {
        Map map = request.getParameterMap();
        try {
            BeanUtils.populate(obj, map);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}
